package cn.tedu._04mybatis.mapper;

import cn.tedu._04mybatis.pojo.entity.Comment;
import cn.tedu._04mybatis.pojo.vo.SelectCommentVO1;
import cn.tedu._04mybatis.pojo.vo.SelectCommentVO2;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentMapper {
    @Insert("INSERT INTO comment(content,created,user_id,weibo_id) VALUES " +
            "(#{content},#{created},#{userId},#{weiboId})")
    void insertComment(Comment comment);

    @Delete("DELETE FROM comment WHERE id = #{commentId}")
    int deleteComment(Long commentId);

    @Update("UPDATE comment SET content = #{content},created = #{created},user_id = #{userId},weibo_id = #{weiboId} WHERE id = #{id}")
    int updateComment(Comment comment);

    @Select("SELECT content,created,user_id userId,weibo_id weiboId FROM comment WHERE id = #{commentId}")
    SelectCommentVO1 selectCommentById1(Long commentId);

    @Select("SELECT content,user_id userId FROM comment WHERE weibo_id = #{weiboId}")
    List<SelectCommentVO2> selectCommentById2(Long weiboId);
}
